import type { ModelProvider } from '@/types/ai-models'

export const AI_PROVIDERS: ModelProvider[] = [
  {
    id: 'qwen',
    name: '通义千问 (Qwen)',
    baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
    defaultModel: 'qwen-plus-latest',
    apiKeyEnvVar: 'VITE_QWEN_API_KEY',
    description: '阿里云通义千问大模型，支持多模态和长文本处理',
    models: [
      {
        id: 'qwen-plus-latest',
        name: 'Qwen Plus Latest',
        maxTokens: 32768,
        description: '最新版本，默认开启深度思考能力（✅已验证可用）',
        pricing: { input: 0.004, output: 0.012, unit: '1K tokens' }
      },
    ]
  },
  {
    id: 'doubao',
    name: '豆包 (Doubao)',
    baseURL: 'https://ark.cn-beijing.volces.com/api/v3',
    defaultModel: 'doubao-seed-1-6-250615',
    apiKeyEnvVar: 'VITE_DOUBAO_API_KEY',
    description: '字节跳动豆包大模型，擅长创作和对话，支持多模态',
    models: [
      {
        id: 'doubao-seed-1-6-250615',
        name: 'Doubao Seed 1.6',
        maxTokens: 250615,
        description: '最新种子模型，具备更强的理解和生成能力，支持多模态（✅已验证可用）',
        pricing: { input: 0.0008, output: 0.002, unit: '1K tokens' }
      }
    ]
  },
  {
    id: 'deepseek',
    name: 'DeepSeek',
    baseURL: 'https://api.deepseek.com/v1',
    defaultModel: 'deepseek-reasoner',
    apiKeyEnvVar: 'VITE_DEEPSEEK_API_KEY',
    description: 'DeepSeek 大模型，擅长代码和逻辑推理',
    models: [
      {
        id: 'deepseek-reasoner',
        name: 'DeepSeek Reasoner',
        maxTokens: 128000,
        description: 'DeepSeek-V3.1 推理模式，具备强大的思维链和推理能力（✅已验证可用）',
        pricing: { input: 0.00055, output: 0.0022, unit: '1K tokens' }
      }
    ]
  }
]

export const getProviderById = (id: string): ModelProvider | undefined => {
  return AI_PROVIDERS.find(provider => provider.id === id)
}

export const getModelById = (providerId: string, modelId: string) => {
  const provider = getProviderById(providerId)
  return provider?.models.find(model => model.id === modelId)
}